package estrutura;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


@SuppressWarnings("serial")
public class Cadastramento extends HttpServlet {
	
	@Override
	protected void doGet(HttpServletRequest request, 
						 HttpServletResponse response)
						 throws ServletException, IOException {
	
		HttpSession session = request.getSession();
		
		ArrayList<Funcionario> funcionarios = (ArrayList<Funcionario>) session.getAttribute("funcionarios");
	
		
		Funcionario trabalhador = new Funcionario();
		
		trabalhador.setNome(request.getParameter("nome"));
		trabalhador.setMatricula(request.getParameter("matricula"));
		trabalhador.setSalario(toString(request.getParameter("salario")));
		funcionarios.add(trabalhador);
		
		session.setAttribute("funcionarios", funcionarios);
		
		
		RequestDispatcher dispatcher = request.getRequestDispatcher("gerar_tabela.jsp");
		dispatcher.forward(request, response);
	
	}

	private int toString(String parameter) {
		// TODO Auto-generated method stub
		return 0;
	}
}
